#include <iostream>
#include <vector>

using namespace std;

class Solution {
public:
    int reverse(int x) {
        if (x == INT_MAX || x == INT_MIN) {
            return 0;
        }
        vector<int64_t> nums;

        int f = (x < 0) ? (-1) : 1;
        x = std::fabs(x);

        while (x > 0) {
            nums.push_back(x % 10);
            x /= 10;
        }

        int y = 0;
        for (auto i : nums) {
            if ((f > 0 ? (INT_MAX - i) : (-(INT_MIN + i))) / 10 < y) {
                return 0;
            }
            y = y * 10 + i;
        }

        return f * y;
    }
};

int main(int argc, char *argv[]) {
    std::cout << Solution().reverse(1534236469) << std::endl;
    return 0;
}